package com.ygh.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ygh.mapper.VipLeftMenuMapper;
import com.ygh.pojo.LeftMenu;
import com.ygh.pojo.VipLeftMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VipLeftMenuServiceImpl implements VipLeftMenuService{
    @Autowired
    private VipLeftMenuMapper vipLeftMenuMapper;

    @Override
    public  List<VipLeftMenu> getLeftList() {
        QueryWrapper<VipLeftMenu> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", 0);
        List<VipLeftMenu> onelist = vipLeftMenuMapper.selectList(queryWrapper);
        for(VipLeftMenu one:onelist){
            QueryWrapper<VipLeftMenu> queryWrapper1 = new QueryWrapper<>();
            queryWrapper1.eq("parent_id", one.getId());
            List<VipLeftMenu> twolist =vipLeftMenuMapper.selectList(queryWrapper1);
            one.setChildren(twolist);
        }
        return onelist;
    }
}
